<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src='../../3-javascript/day14/jquery.js'></script>
</head>
<body>
    
</body>
<script>
    //设置请求头
    $.ajaxSetup({
        headers:{
            'Content-Type': 'application/json',
            'Authorization':localStorage.getItem('token')
        }
    })
    //设置基路径
    var baseUrl = 'http://47.93.206.13:8002'
    //登录请求
    function login(){
        var form = {
            username:'admin1', 
            password:'123321'
        }
        //与后台交互
        $.post(baseUrl+'/user/login',JSON.stringify(form),function(res){
            if(res.status === 200){
                //登录成功之后将token保存起来
                localStorage.setItem('token',res.data.token)
            }
        })
    }
    //查询所有用户
    function findAllUser(){
        $.get(baseUrl+'/baseUser/cascadeRoleFindAll',function(res){
            console.log(res);
        })
    }
    //方法的调用
    login()
    findAllUser()
</script>
</html>